<?

include_once '/var/www/html/new/com.inc.php';
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$aid=$_SESSION['sid'];
$btime=$_REQUEST['bt']?  $_REQUEST['bt']:date('Y-m-d',strtotime("-30days"));
$etime=$_REQUEST['et']?  $_REQUEST['et']:date('Y-m-d');
$bt= $btime .' 00:00:00';
$et = $etime .' 23:59:59';
$lid_arr=array();
//取已销售的景区数据,自供自销的；
$x_ob1 = simplexml_load_string($s -> Order_Globle_Search(
    "","$aid", "", "", "", "", "$bt", "$et", "", "",
    "", "", "", "", "", "1", "", "", "1", "1",
    "0", "1000", "0", "0","","0","0", "0","","",
    "", "", "", "", ""));

foreach($x_ob1->Rec as $key1=>$val1)
{if($val1->UUpmode==3)
    $lid_arr[(string)$val1->UUlid]=$val1->UUltitle;

}
//取供应商已销售的景区；
$x_ob2 = simplexml_load_string($s -> Order_Globle_Search(
    "","", "", "", "", "", "$bt", "$et", "", "",
    "", "", "", "", "", "1", "", "", "1", "1",
    "0", "1000", "0", "0","","0","0", "0","","",
    "$aid", "", "", "", ""));
//print_r($x_ob2);
foreach($x_ob2->Rec as $key2=>$val2){
    $lid_arr[ (string)$val2->UUlid ]=$val2->UUltitle;

}

$lid_arr=array_unique($lid_arr);

//取景区票数
if(count($lid_arr)!=0){
    foreach($lid_arr as $lid=>$vt){
        $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "$bt", "$et", "", "",
        "", "", "", "", "", "", "", "", "1", "1",
        "0", "800", "2", "0","","0","0", "0","","",
        "$aid", "", "", "", "");

        $x=explode(',',$x);
        $x=$x[1];
//取自供自销票数
        $x2 = simplexml_load_string($s -> Order_Globle_Search(
            "","$aid", "$lid", "", "", "", "$bt", "$et", "", "",
            "", "", "", "", "", "", "", "", "1", "1",
            "0", "800", "0", "0","","0","0", "0","","",
            "", "", "", "", ""));
        $var=0;
        foreach($x2->Rec as $k=>$v){
            $vb=(string)$v->UUpmode;
            if($vb==3){
                $var+=$v->UUtnum;
            }

        }

        $UUt[(string)$vt]=$x+$var;


    }


    $out=arsort($UUt);
    //取前10位产品；
    $UUt=count($UUt)>=10? array_slice($UUt,0,10):$UUt;




}
if(count($lid_arr)==0)
{echo"<script>alert('所选时间段无产品,请重新选择日期！！！');</script>";}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <script language="javascript" src="http://www.12301.cc/js/WdatePicker.js"></script>
    <script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
</head>
<body>
<form action="" method="post"  name="form" >
    <span class="lt">时间：</span>
    <input type="text" data-t="bt" id="txtStartTime" value="<?=$_REQUEST['bt']?>" name="bt" data-msg="请选择时间段" class="textInp w175 alliNameInp" autocomplete="off"/> 至
    <input type="text" data-t="et" id="txtEndTime" value="<?=$_REQUEST['et']?>" name="et" data-msg="请选择时间段" class="textInp w175 alliNameInp" autocomplete="off"/>

    <input type="submit" value="提交">
</form>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="height:400px;width:800px"></div>
<!-- ECharts单文件引入 -->
<script src="//www.12301.cc/js/echarts-2.2.0/build/dist/echarts.js"></script>
<script type="text/javascript">
    // 路径配置
    require.config({
        paths: {
            echarts: '//www.12301.cc/js/echarts-2.2.0/build/dist'
        }
    });

    // 使用
    require(
        [
            'echarts',
            'echarts/chart/bar' // 使用柱状图就加载bar模块
        ],
        function (ec) {
            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('main'));

            var option = {
                title: {
                    x: 'center',
                    text: '产品销售票数统计',



                },
                tooltip: {
                    trigger: 'item'
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark : {show: false},
                        dataView: {show: true, readOnly: false},
                        restore: {show: true},
                        saveAsImage: {show: true}
                    }
                },
                calculable: true,
                grid: {
                    borderWidth: 0,
                    y: 80,
                    y2: 60
                },
                xAxis: [
                    {
                        type: 'category',
                        show: false,
                        data: [<?foreach($UUt as $key=>$v)
	 {$str.="'".$key."',";}
	 $str=substr($str,0,-1);
	 echo $str;?>]
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        show: true
                    }
                ],
                series: [
                    {
                        name: '产品票数统计',
                        type: 'bar',
                        itemStyle: {
                            normal: {
                                color: function(params) {
                                    // build a color map as your need.
                                    var colorList = [
                                        '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
                                        '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
                                        '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0'
                                    ];
                                    return colorList[params.dataIndex]
                                },
                                label: {
                                    show: true,
                                    position: 'top',
                                    formatter: '{b}\n{c}'
                                }
                            }
                        },
                        data: [<?foreach($UUt as $tl=>$v){
				$tmp .= "'".$v."',";
			}
			$tmp =substr($tmp,0,-1);
			echo $tmp;
			?>] ,
                        markPoint: {
                            tooltip: {
                                trigger: 'item',
                                backgroundColor: 'rgba(0,0,0,0)',
                                formatter: function(params){
                                    return '<img src="'
                                        + params.data.symbol.replace('image://', '')
                                        + '"/>';
                                }
                            },
                            data: [

                            ]
                        }
                    }
                ]
            };
            // 为echarts对象加载数据
            myChart.setOption(option);
        }
    );



    $("#txtStartTime").bind("click focus", function () {

        var endtimeTf = $dp.$('txtEndTime');
        WdatePicker({
            maxDate: '#F{$dp.$D(\'txtEndTime\')}',
            dateFmt: "yyyy-MM-dd",
            onpicked: function () { endtimeTf.focus(); }
        });
    });
    $("#txtEndTime").bind("click focus", function () {
        WdatePicker({
            minDate: '#F{$dp.$D(\'txtStartTime\')}',
            dateFmt: "yyyy-MM-dd"
        });
    });

</script>
</body>
</html>